//
//  TGLEEAlert.m
//
//  Created by Dean on 2018/5/24.
//  Copyright © 2018年 Dean. All rights reserved.
//

#import "TGLEEAlert.h"

static NSTimer * timer = nil;
@interface TGLEEAlert ()<TTTAttributedLabelDelegate,UITextFieldDelegate>


@end
@implementation TGLEEAlert

+(instancetype)shareInstance {
    
    static dispatch_once_t onceToken;
    static TGLEEAlert *_share =nil;
    dispatch_once(&onceToken, ^{
        _share = [[TGLEEAlert alloc] init];
    });
    return _share;
}
+(void)alertTitle:(NSString *)title message:(NSString *)msg
{
    
    LEEAlertConfig *config =  [LEEAlert alert];
//    config.config.LeeClickBackgroundClose(flag);
    config.config.LeeMaxWidth(RatioWidth(270));
    config.config.LeeStatusBarStyle(UIStatusBarStyleLightContent);
    config.config.LeeBackgroundStyleTranslucent(.4);
    config.config.LeeCornerRadius(TableViewCornerRadius);
    config.config.LeeShadowOpacity(0.2);
    if (title) {
        config.config.LeeAddTitle(^(UILabel * _Nonnull label) {
            label.textColor = RGBA(60, 60, 60, 1);
            label.font = TGBlodAFont(16);
            label.text = title;
        });
    }
 
    if (msg) {
        config.config.LeeAddContent(^(UILabel *label) {
            label.textColor = RGB(51,51, 51);
            NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
            paraStyle.lineSpacing = 8.0;
            paraStyle.alignment = NSTextAlignmentCenter;
            label.attributedText = [[NSMutableAttributedString alloc] initWithString:msg attributes: @{NSFontAttributeName: TGAutoFont(15), NSParagraphStyleAttributeName: paraStyle}];
        });
    }
        config.config.LeeAddAction(^(LEEAction *action){
            action.borderColor = RGBA(239, 239, 239, 1);
            action.title = @"确定";
            action.titleColor = RedColor;
            action.font = TGAutoFont(18);
        });
    
    config.config.LeeShow();
}
+ (void)actionMessage:(NSString *)message cancelTitle:(NSString*)cancelTitle buttons:(NSArray *)buttons  click:(void(^)(NSInteger index))clickBlock
{
    
    LEEAlertConfig *config =  (LEEAlertConfig *)[LEEAlert actionsheet];
    config.config.LeeCancelAction(cancelTitle, ^{

    });
    config.config.LeeStatusBarStyle(UIStatusBarStyleLightContent);
    
    for (int i=0; i<buttons.count; i++) {
        NSString *str = buttons[i];
        config.config.LeeAction(str, ^{
            if (clickBlock) {
                clickBlock(i);
            }
        });
    }
    config.config.LeeShow();
    
}
+ (void)alertYelloMessage:(NSString *)message cancelTitle:(NSString*)cancelTitle sureTitle:(NSString*)sureTitle  click:(void(^)(NSInteger index))clickBlock clickBackgroundClose:(BOOL)flag{
    
    [LEEAlert alert].config
    .LeeAlertCenterOffset(CGPointMake(0, (-70)))    .LeeStatusBarStyle(UIStatusBarStyleLightContent)
    .LeeClickBackgroundClose(flag)
    .LeeAddCustomView(^(LEECustomView *custom) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, RatioWidth(56), RatioWidth(57))];
        imageView.image = kImage(@"hd_gantanhao_icon");
        custom.view = imageView;
        custom.positionType = LEECustomViewPositionTypeCenter;
    })
    .LeeAddContent(^(UILabel *label) {
        label.text = message;
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = RGBA(153, 153, 153, 1);
    }).LeeAddAction(^(LEEAction *action){
        action.title = cancelTitle;
        action.titleColor = RGBA(153, 153, 153, 1);
        action.font =[UIFont systemFontOfSize:16];
        action.clickBlock = ^{
            if (clickBlock) {
                clickBlock(0);
            }
        };
    })
    .LeeAddAction(^(LEEAction *action){
        action.title = sureTitle;
        action.titleColor = RGBA(255, 174, 0, 1);
        action.font =[UIFont systemFontOfSize:16];
        action.clickBlock = ^{
            if (clickBlock) {
                clickBlock(1);
            }
        };
    })
    .LeeShow();
}
+ (void)alertMessage:(NSString *)message cancelTitle:(NSString*)cancelTitle sureTitle:(NSString*)sureTitle  click:(void(^)(NSInteger index))clickBlock clickBackgroundClose:(BOOL)flag{
    
    [self alertTitle:nil message:message cancelTitle:cancelTitle sureTitle:sureTitle clickBackgroundClose:flag click:clickBlock];
}

+ (void)alertMessage:(NSString *)message sureTitle:(NSString*)sureTitle  click:(void(^)(NSInteger index))clickBlock {
    [self alertMessage:message cancelTitle:nil sureTitle:sureTitle click:clickBlock clickBackgroundClose:NO];

}

+ (void)alertTitle:(NSString *)title message:(NSString *)message sureTitle:(NSString*)sureTitle  click:(void(^)(NSInteger index))clickBlock {
    [self alertTitle:title message:message cancelTitle:nil sureTitle:sureTitle click:clickBlock];
}

+ (void)alertMessage:(NSString *)message cancelTitle:(NSString*)cancelTitle sureTitle:(NSString*)sureTitle  click:(void(^)(NSInteger index))clickBlock {
    [self alertMessage:message cancelTitle:cancelTitle sureTitle:sureTitle click:clickBlock clickBackgroundClose:NO];

}


+ (void)alertAgreementSuccessClick:(void(^)(void))clickBlock {
    
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-RatioWidth(75), RatioHeight(485))];
  
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, RatioHeight(15), view.width, view.height - RatioHeight(25))];
    [view addSubview:scrollView];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(AverageFloat(view.width, RatioWidth(108)), RatioHeight(15), RatioWidth(108), RatioWidth(89))];
    imageView.image = UIImageMakeWithFile(@"xieyiLogo");
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    [scrollView addSubview:imageView];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, RatioHeight(127), view.width, RatioHeight(15))];
    label.textAlignment = NSTextAlignmentCenter;
    label.adjustsFontSizeToFitWidth = YES;
    label.font = TGBlodAFont(15);
    label.textColor = RGBA(51, 51, 51, 1);
    [scrollView addSubview:label];
    label.text = @"隐私政策";
    TTTAttributedLabel *contentLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(RatioWidth(17), label.bottom+10, view.width - RatioWidth(17)*2, 0)];
     contentLabel.numberOfLines = 0;
     contentLabel.textColor = RGB(153, 153, 153);
     contentLabel.delegate = [TGLEEAlert shareInstance];
     contentLabel.userInteractionEnabled = YES;
     contentLabel.enabledTextCheckingTypes = NSTextCheckingTypeLink;
     NSString *text = [NSString stringWithFormat:@"\u3000\u3000欢迎使用指乎App，在您使用期间需要连接数据网络或者WLAN，产生的流量费用请咨询当地运营商。指乎App所采集的信息用于为您提供优质的服务体验，保障您的个人信息，资金安全，请在使用前仔细阅读《隐私政策》条款，同意后开启我们的服务。\n\u3000\u3000在使用指乎期间，我们会申请获取您的系统权限 。为给您提供附近优惠、我们会申请访问位置信息权限；为记录您的登录设备和状态，我们会申请读取您的手机状态和身份。同时，在使用过程中，我们还会申请获取您的手机相册权限、使用照相设备权限、通知权限等。\n\u3000\u3000为方便您的查阅，可在登录App后在我的-》设置-》隐私-》隐私权政策条款中查看完整版隐私政策内容。我们的产品集成友盟+SDK，友盟+SDK需要收集您的设备Mac地址、唯一设备识别码（IMEI/android ID/IDFA/OPENUDID/GUID、SIM 卡 IMSI 信息）以提供统计分析服务，并通过地理位置校准报表数据准确性，提供基础反作弊能力。"];
     
     NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:text];

     NSRange rangeAll = NSMakeRange(0, text.length);
     [attString addAttribute:NSForegroundColorAttributeName value:RGBA(102, 102, 102, 1) range:rangeAll];
    [attString addAttribute:NSFontAttributeName value: TGAutoFont(12) range:rangeAll];
    NSRange range1  = [attString.string rangeOfString:@"《隐私政策》"];
    [attString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:range1];
     NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
     [paragraphStyle setLineSpacing:(3)];
     paragraphStyle.alignment=NSTextAlignmentJustified;
    NSDictionary * dic =@{
                          //这两个一定要加哦。否则就没效果啦
                          NSParagraphStyleAttributeName:paragraphStyle,
                          NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone],
                          };
    [attString addAttributes:dic range:NSMakeRange(0, text.length)];
//     [attString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, text.length)];
     contentLabel.text = attString;
     contentLabel.linkAttributes = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:(NSString *)kCTUnderlineStyleAttributeName];
     [contentLabel addLinkToURL:nil withRange:range1];
     [contentLabel sizeToFit];
     [scrollView addSubview:contentLabel];
     scrollView.contentSize = CGSizeMake(scrollView.width, contentLabel.bottom);
    
    [LEEAlert alert].config
    .LeeBackgroundStyleTranslucent(.4)
    .LeeCornerRadius(TableViewCornerRadius)
    .LeeShadowOpacity(0.2)
    .LeeStatusBarStyle(UIStatusBarStyleLightContent)
    .LeeMaxWidth(SCREEN_WIDTH-RatioWidth(75)) // 设置最大宽度 (固定数值 横竖屏相同)
    .LeeMaxHeight(RatioHeight(550))
    .LeeHeaderInsets(UIEdgeInsetsMake(0, 0, 0, 0))
    .LeeAddCustomView(^(LEECustomView *custom) {
        custom.view = view;
        custom.isAutoWidth = YES;
        custom.positionType = LEECustomViewPositionTypeCenter;
    })
    .LeeAddAction(^(LEEAction *action){
        action.height = (44);
        action.borderColor = RGB(247, 247, 247);
        action.title = @"退出";
        action.titleColor = RGBA(153, 153, 153, 1);
        action.font = TGAutoFont(18);
    })
    .LeeAddAction(^(LEEAction *action){
        action.height = (44);
        action.borderColor = RGB(247, 247, 247);
        action.title = @"同意";
        action.titleColor = RedColor;
        action.font = TGAutoFont(18);
        action.clickBlock = ^{
            if (clickBlock) {
                clickBlock();
            }
        };
    })
    .LeeShow();
    
}

+ (void)alertReigsterAgreementSuccessClick:(void(^)(void))clickBlock{
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH-RatioWidth(75), (90))];
    TTTAttributedLabel *contentLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake((15), 0, view.width - (15)*2, (90))];
     contentLabel.numberOfLines = 0;
     contentLabel.contentMode= UIViewContentModeCenter;
     contentLabel.textColor = RGB(153, 153, 153);
     contentLabel.delegate = [TGLEEAlert shareInstance];
     contentLabel.userInteractionEnabled = YES;
     contentLabel.adjustsFontSizeToFitWidth = YES;
     contentLabel.accessibilityIdentifier = @"zhuce";
     contentLabel.enabledTextCheckingTypes = NSTextCheckingTypeLink;
    [view addSubview:contentLabel];
    NSString *text = [NSString stringWithFormat:@"请您仔细阅读《用户服务协议》条款，同意后可以开始使用我们的服务"];
     NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:text];
     NSRange rangeAll = NSMakeRange(0, text.length);
     [attString addAttribute:NSForegroundColorAttributeName value:UIColorBlack range:rangeAll];
    [attString addAttribute:NSFontAttributeName value: TGAutoFont(14) range:rangeAll];
    NSRange range1  = [attString.string rangeOfString:@"《用户服务协议》"];
    [attString addAttribute:NSForegroundColorAttributeName value:GlobalBarTinColor range:range1];
     NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
     [paragraphStyle setLineSpacing:(2)];
     paragraphStyle.alignment=NSTextAlignmentJustified;
    NSDictionary * dic =@{
                          //这两个一定要加哦。否则就没效果啦
                          NSParagraphStyleAttributeName:paragraphStyle,
                          NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone]
                          };
    [attString addAttributes:dic range:NSMakeRange(0, text.length)];
     contentLabel.text = attString;
     contentLabel.linkAttributes = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:(NSString *)kCTUnderlineStyleAttributeName];
     [contentLabel addLinkToURL:nil withRange:range1];
    [LEEAlert alert].config
    .LeeBackgroundStyleTranslucent(.4)
    .LeeCornerRadius(TableViewCornerRadius)
    .LeeShadowOpacity(0.2)
    .LeeStatusBarStyle(UIStatusBarStyleLightContent)
    .LeeMaxWidth(SCREEN_WIDTH-RatioWidth(75)) // 设置最大宽度 (固定数值 横竖屏相同)
    .LeeMaxHeight(RatioHeight(200))
    .LeeHeaderInsets(UIEdgeInsetsMake(0, 0, 0, 0))
    .LeeAddCustomView(^(LEECustomView *custom) {
        custom.view = view;
        custom.isAutoWidth = YES;
        custom.positionType = LEECustomViewPositionTypeCenter;
    })
    .LeeAddAction(^(LEEAction *action){
        action.height = (44);
        action.borderColor = RGB(247, 247, 247);
        action.title = @"不同意";
        action.titleColor = RGBA(153, 153, 153, 1);
        action.font = TGAutoFont(16);
    })
    .LeeAddAction(^(LEEAction *action){
        action.height = (44);
        action.borderColor = RGB(247, 247, 247);
        action.title = @"同意";
//        action.titleColor = RedColor;
        action.titleColor = GlobalBarTinColor;
        action.font = TGAutoFont(16);
        action.clickBlock = ^{
            if (clickBlock) {
                clickBlock();
            }
        };
    })
    .LeeShow();
    
    
}

- (void)attributedLabel:(TTTAttributedLabel *)label
   didSelectLinkWithURL:(NSURL *)url  {
  
}
+ (void)alertTipImage:(NSString *)message cancel:(NSString*)cancel  click:(void(^)(NSInteger index))clickBlock{
   

    [LEEAlert alert].config
    .LeeStatusBarStyle(UIStatusBarStyleLightContent)
    .LeeMaxWidth(SCREEN_WIDTH-RatioWidth(68)) // 设置最大宽度 (固定数值 横竖屏相同)
    .LeeAddCustomView(^(LEECustomView *custom) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
        imageView.image = kImage(@"plaint_icon");
        custom.view = imageView;
        custom.positionType = LEECustomViewPositionTypeCenter;
    }).LeeAddContent(^(UILabel *label) {
        label.text = message;
        label.font = [UIFont systemFontOfSize:15];
        
    }).LeeAddAction(^(LEEAction *action){
        action.title = cancel;
        action.titleColor = [UIColor blackColor];
        action.font =[UIFont systemFontOfSize:18];
        action.clickBlock = ^{
            if (clickBlock) {
                clickBlock(0);
            }
        };
    })
    .LeeAddAction(^(LEEAction *action){
        action.title = @"确定";
        action.titleColor = RGB(52, 145, 248);
        action.font =[UIFont systemFontOfSize:18];
        action.clickBlock = ^{
            if (clickBlock) {
                clickBlock(1);
            }
        };
    })
    .LeeShow();
}
+ (void)alertSuccess:(NSString *)message click:(void(^)(void))clickBlock{
    
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, RatioWidth(64), RatioWidth(64))];
    imageView.image = kImage(@"success_icon");
    [LEEAlert alert].config
    .LeeBackgroundStyleTranslucent(.4)
    .LeeCornerRadius(TableViewCornerRadius)
    .LeeShadowOpacity(0.2)
    .LeeStatusBarStyle(UIStatusBarStyleLightContent)
    .LeeMaxWidth(SCREEN_WIDTH-RatioWidth(80)) // 设置最大宽度 (固定数值 横竖屏相同)
    .LeeAddCustomView(^(LEECustomView *custom) {
        custom.view = imageView;
        custom.positionType = LEECustomViewPositionTypeCenter;
    }).LeeAddContent(^(UILabel *label) {
        label.text = message;
        label.font = TGAutoFont(14);
        label.textColor = RGBA(51, 5, 51, 1);
    })
    .LeeAddAction(^(LEEAction *action){
        action.borderColor = RGB(247, 247, 247);
        action.title = @"确定";
        action.titleColor = TitleBlackColor;
        action.font = TGAutoFont(18);
        action.clickBlock = ^{
            if (clickBlock) {
                clickBlock();
            }
        };
    })
    .LeeShow();
}
+ (LEEAlertConfig *)alertTitle:(NSString*)title message:(NSString *)message cancelTitle:(NSString*)cancelTitle sureTitle:(NSString*)sureTitle  click:(void(^)(NSInteger index))clickBlock   {
   return [self alertTitle:title message:message cancelTitle:cancelTitle sureTitle:sureTitle clickBackgroundClose:YES click:clickBlock];
}
+ (LEEAlertConfig *)alertTitle:(NSString*)title message:(NSString *)message cancelTitle:(NSString*)cancelTitle sureTitle:(NSString*)sureTitle  clickBackgroundClose:(BOOL)flag click:(void(^)(NSInteger index))clickBlock  {
    
    
    LEEAlertConfig *config =  [LEEAlert alert];
    config.config.LeeClickBackgroundClose(flag);
    config.config.LeeMaxWidth(SCREEN_WIDTH-RatioWidth(68));
    config.config.LeeStatusBarStyle(UIStatusBarStyleLightContent);
    config.config.LeeBackgroundStyleTranslucent(.4);
    config.config.LeeCornerRadius(TableViewCornerRadius);
    config.config.LeeShadowOpacity(0.2);
    config.config.LeeCornerRadius(10);
    if (title) {
        config.config.LeeAddTitle(^(UILabel *label) {
            label.text = title;
        });
    }
    config.config.LeeAddContent(^(UILabel *label) {
        label.textColor = RGB(51,51, 51);
        NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
        paraStyle.lineSpacing = 8.0;
        paraStyle.alignment = NSTextAlignmentCenter;
        label.attributedText = [[NSMutableAttributedString alloc] initWithString:message attributes: @{NSFontAttributeName:  TGAutoFont(15), NSParagraphStyleAttributeName: paraStyle}];
    });
    if (cancelTitle) {
        config.config.LeeAddAction(^(LEEAction *action){
            action.borderColor = RGB(231,231,231);
            action.title = cancelTitle;
            action.titleColor = DeepGrayColor;
            action.font = TGMediumAFont(16);
            action.height = RatioWidth(50);
            action.clickBlock = ^{
                if (clickBlock) {
                    clickBlock(0);
                }
            };
        });
    }
    if (sureTitle) {
        config.config.LeeAddAction(^(LEEAction *action){
            action.borderColor = RGB(231,231,231);
            action.title = sureTitle;
//            action.titleColor = RGBA(229, 28, 35, 1);
            action.titleColor = GlobalBarTinColor;
            action.font = TGMediumAFont(16);
            action.height = RatioWidth(50);
            action.clickBlock = ^{
                if (clickBlock) {
                    clickBlock(1);
                }
            };
        });
    }
    
    config.config.LeeShow();
    
    return config;
    
}

+ (LEEAlertConfig *)alertTitle:(NSString*)title messageAttributed:(NSAttributedString *)messageAttributed cancelTitle:(NSString*)cancelTitle sureTitle:(NSString*)sureTitle  clickBackgroundClose:(BOOL)flag click:(void(^)(NSInteger index))clickBlock  {
    
    LEEAlertConfig *config =  [LEEAlert alert];
    config.config.LeeClickBackgroundClose(flag);
    config.config.LeeMaxWidth(SCREEN_WIDTH-RatioWidth(68));
    config.config.LeeStatusBarStyle(UIStatusBarStyleLightContent);
    config.config.LeeBackgroundStyleTranslucent(.4);
    config.config.LeeCornerRadius(TableViewCornerRadius);
    config.config.LeeShadowOpacity(0.2);
    if (title) {
        config.config.LeeAddTitle(^(UILabel *label) {
            label.text = title;
        });
    }
    config.config.LeeAddContent(^(UILabel *label) {
        label.textColor = RGB(51,51, 51);
        label.attributedText = messageAttributed;
    });
    if (cancelTitle) {
        config.config.LeeAddAction(^(LEEAction *action){
            action.borderColor = RGB(231,231,231);
            action.title = cancelTitle;
            action.titleColor = DeepGrayColor;
            action.font = TGAutoFont(18);
            action.clickBlock = ^{
                if (clickBlock) {
                    clickBlock(0);
                }
            };
        });
    }
    if (sureTitle) {
        config.config.LeeAddAction(^(LEEAction *action){
            action.borderColor = RGB(231,231,231);
            action.title = sureTitle;
            action.titleColor = RGBA(229, 28, 35, 1);
            action.font = TGAutoFont(18);
            action.clickBlock = ^{
                if (clickBlock) {
                    clickBlock(1);
                }
            };
        });
    }
    
    config.config.LeeShow();
    
    return config;
    
}

//创建客户弹窗
+(void)workBenchCustomerAddActionClick:(void(^)(NSInteger index))clickBlock {
        [LEEAlert actionsheet].config
       .LeeStatusBarStyle(UIStatusBarStyleLightContent)
       .LeeAddAction(^(LEEAction * _Nonnull action) {
           action.title = @"个人客户（可添加未认证客户）";
           action.titleColor = RGBA(51, 51, 51, 1);
           action.font = TGAutoFont(16);
           action.clickBlock = ^{
               if (clickBlock) {
                   clickBlock(0);
               }
           };
       })
       .LeeAddAction(^(LEEAction * _Nonnull action) {
           action.title = @"企业客户";
           action.titleColor = RGBA(51, 51, 51, 1);
           action.font = TGAutoFont(16);
           action.clickBlock = ^{
               if (clickBlock) {
                   clickBlock(1);
                }
           };
       })
        .LeeAddAction(^(LEEAction * _Nonnull action) {
            action.title = @"取消";
            action.titleColor = RGBA(51, 51, 51, 1);
            action.font = TGAutoFont(16);
            action.clickBlock = ^{
            };
        })
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
        .LeeActionSheetBackgroundColor([UIColor whiteColor])
        .LeeCornerRadii(CornerRadiiMake(10, 10, 0, 0))   // 指定整体圆角半径
        .LeeConfigMaxWidth(^CGFloat(LEEScreenOrientationType type, CGSize size)  {
            return CGRectGetWidth([[UIScreen mainScreen] bounds]);
        }).LeeShow();
    
}


//创建客户第一步手机号码校验结果弹窗---客户已存在，但未认证
+(void)workBenchCreateCustomUnAuthActionClick:(void(^)(NSInteger index))clickBlock {
   
    UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, RatioWidth(115), RatioWidth(320), RatioWidth(56))];
    
    bottomView.backgroundColor = UIColorWhite;
    bottomView.layer.cornerRadius = TableViewCornerRadius;
    bottomView.qmui_borderColor = RGB(231, 231, 231);
    bottomView.qmui_borderPosition = QMUIViewBorderPositionTop;
    NSArray *titles = @[@"取消", @"直接同步", @"去认证"];
    CGFloat btnWidth = bottomView.width/3.0;
    for (int i = 0; i<3; i++) {
        QMUIButton *tempBtn = [QMUIButton buttonWithType:UIButtonTypeCustom];
        [tempBtn setTitle:titles[i] forState:UIControlStateNormal];
        [tempBtn setTitleColor:i==2?GlobalBarRedTinColor:DeepBlackColor forState:UIControlStateNormal];
        if (i == 1) {
            tempBtn.qmui_borderColor = RGB(231, 231, 231);
            tempBtn.qmui_borderPosition = QMUIViewBorderPositionLeft|QMUIViewBorderPositionRight;
        }
        [tempBtn addBlockForControlEvents:UIControlEventTouchUpInside block:^(id  _Nonnull sender) {
            if (clickBlock) {
                clickBlock(i);
            }
        }];
        tempBtn.frame = CGRectMake(btnWidth*i, 0, btnWidth, bottomView.height);
        [bottomView addSubview:tempBtn];
    }
    
    
    
    [LEEAlert alert].config
        .LeeStatusBarStyle(UIStatusBarStyleLightContent)
        .LeeMaxWidth(RatioWidth(320)) // 设置最大宽度 (固定数值 横竖屏相同)
        .LeeMaxHeight(RatioWidth(168))
        .LeeAddTitle(^(UILabel * _Nonnull label) {
            label.text = @"客户已存在";
            label.font = TGMediumAFont(18);
            label.textColor = DeepBlackColor;
            label.textAlignment = NSTextAlignmentCenter;
        })
        .LeeAddContent(^(UILabel *label) {
            label.textColor = DeepGrayColor;
            NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
            paraStyle.lineSpacing = 8.0;
            paraStyle.alignment = NSTextAlignmentCenter;
            label.attributedText = [[NSMutableAttributedString alloc] initWithString:@"当前人员已存在,您可查看客户信息" attributes: @{NSFontAttributeName: TGAutoFont(15), NSParagraphStyleAttributeName: paraStyle}];
            label.height = RatioWidth(40);
        })
        .LeeItemInsets(UIEdgeInsetsMake(10, 0, 20, 0))
        .LeeAddCustomView(^(LEECustomView *custom) {
            custom.view = bottomView;
            custom.isAutoWidth = YES;
            custom.positionType = LEECustomViewPositionTypeCenter;
        })
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
        .LeeActionSheetBackgroundColor([UIColor whiteColor])
        .LeeCornerRadii(CornerRadiiMake(10, 10, 10, 10))   // 指定整体圆角半径
        .LeeHeaderInsets(UIEdgeInsetsMake(20, 0, 0, 0))
        .LeeShow();
    
}


//创建拜访弹窗
+(void)workBenchVisitAddActionTitle:(NSString *)title
                              click:(void(^)(NSInteger index))clickBlock {
        [LEEAlert actionsheet].config
       .LeeStatusBarStyle(UIStatusBarStyleLightContent)
       .LeeAddTitle(^(UILabel * _Nonnull label) {
           label.text = title;
           label.font = TGAutoFont(14);
           label.textColor = LightGrayColor;
           label.textAlignment = NSTextAlignmentCenter;
       })
       .LeeAddAction(^(LEEAction * _Nonnull action) {
           action.title = @"陌拜";
           action.titleColor = RGBA(51, 51, 51, 1);
           action.font = TGAutoFont(16);
           action.clickBlock = ^{
               if (clickBlock) {
                   clickBlock(0);
               }
           };
       })
       .LeeAddAction(^(LEEAction * _Nonnull action) {
           action.title = @"客户拜访";
           action.titleColor = RGBA(51, 51, 51, 1);
           action.font = TGAutoFont(16);
           action.clickBlock = ^{
               if (clickBlock) {
                   clickBlock(1);
                }
           };
       })
       .LeeAddAction(^(LEEAction * _Nonnull action) {
           action.title = @"商机拜访";
           action.titleColor = RGBA(51, 51, 51, 1);
           action.font = TGAutoFont(16);
           action.clickBlock = ^{
               if (clickBlock) {
                   clickBlock(2);
               }
           };
       })
       .LeeAddAction(^(LEEAction * _Nonnull action) {
            action.title = @"取消";
            action.titleColor = RGBA(51, 51, 51, 1);
            action.font = TGAutoFont(16);
            action.clickBlock = ^{
                if (clickBlock) {
                    clickBlock(3);
                }
            };
        })
        .LeeClickBackgroundClose(NO)
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
        .LeeActionSheetBackgroundColor([UIColor whiteColor])
        .LeeCornerRadii(CornerRadiiMake(10, 10, 0, 0))   // 指定整体圆角半径
        .LeeConfigMaxWidth(^CGFloat(LEEScreenOrientationType type, CGSize size)  {
            return CGRectGetWidth([[UIScreen mainScreen] bounds]);
        }).LeeShow();
    
}

//创建拜访详情中选择详细结果弹窗

+(void)workBenchVisitDetailChooseResultActionClick:(void(^)(NSInteger index))clickBlock {
        [LEEAlert actionsheet].config
       .LeeStatusBarStyle(UIStatusBarStyleLightContent)
       .LeeAddTitle(^(UILabel * _Nonnull label) {
           label.text = @"请选择拜访详细结果";
           label.font = TGAutoFont(14);
           label.textColor = LightGrayColor;
           label.textAlignment = NSTextAlignmentCenter;
       })
       .LeeAddAction(^(LEEAction * _Nonnull action) {
           action.title = @"现在存在用车意愿";
           action.titleColor = RGBA(51, 51, 51, 1);
           action.font = TGAutoFont(16);
           action.clickBlock = ^{
               if (clickBlock) {
                   clickBlock(0);
               }
           };
       })
       .LeeAddAction(^(LEEAction * _Nonnull action) {
           action.title = @"需继续跟进";
           action.titleColor = RGBA(51, 51, 51, 1);
           action.font = TGAutoFont(16);
           action.clickBlock = ^{
               if (clickBlock) {
                   clickBlock(1);
                }
           };
       })
       .LeeAddAction(^(LEEAction * _Nonnull action) {
           action.title = @"未来存在用车意愿";
           action.titleColor = RGBA(51, 51, 51, 1);
           action.font = TGAutoFont(16);
           action.clickBlock = ^{
               if (clickBlock) {
                   clickBlock(2);
                }
           };
       })
        .LeeAddAction(^(LEEAction * _Nonnull action) {
            action.title = @"取消";
            action.titleColor = RGBA(51, 51, 51, 1);
            action.font = TGAutoFont(16);
            action.clickBlock = ^{
            };
        })
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
        .LeeActionSheetBackgroundColor([UIColor whiteColor])
        .LeeCornerRadii(CornerRadiiMake(10, 10, 0, 0))   // 指定整体圆角半径
        .LeeConfigMaxWidth(^CGFloat(LEEScreenOrientationType type, CGSize size)  {
            return CGRectGetWidth([[UIScreen mainScreen] bounds]);
        }).LeeShow();
    
}

//创建拜访详情中商机拜访装填选择弹窗
+(void)workBenchVisitDetailChooseOpportunityStateActionClick:(void(^)(NSInteger index))clickBlock {
        [LEEAlert actionsheet].config
       .LeeStatusBarStyle(UIStatusBarStyleLightContent)
       .LeeAddTitle(^(UILabel * _Nonnull label) {
           label.text = @"请选择拜访详细结果";
           label.font = TGAutoFont(14);
           label.textColor = LightGrayColor;
           label.textAlignment = NSTextAlignmentCenter;
       })
       .LeeAddAction(^(LEEAction * _Nonnull action) {
           action.title = @"跟进中";
           action.titleColor = RGBA(51, 51, 51, 1);
           action.font = TGAutoFont(16);
           action.clickBlock = ^{
               if (clickBlock) {
                   clickBlock(0);
               }
           };
       })
       .LeeAddAction(^(LEEAction * _Nonnull action) {
           action.title = @"商机失败";
           action.titleColor = RGBA(51, 51, 51, 1);
           action.font = TGAutoFont(16);
           action.clickBlock = ^{
               if (clickBlock) {
                   clickBlock(1);
                }
           };
       })
        .LeeAddAction(^(LEEAction * _Nonnull action) {
            action.title = @"取消";
            action.titleColor = RGBA(51, 51, 51, 1);
            action.font = TGAutoFont(16);
            action.clickBlock = ^{
            };
        })
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
        .LeeActionSheetBackgroundColor([UIColor whiteColor])
        .LeeCornerRadii(CornerRadiiMake(10, 10, 0, 0))   // 指定整体圆角半径
        .LeeConfigMaxWidth(^CGFloat(LEEScreenOrientationType type, CGSize size)  {
            return CGRectGetWidth([[UIScreen mainScreen] bounds]);
        }).LeeShow();
    
}



//创建拜访详情中拜访终止弹窗
+(void)workBenchVisitDetailStopActionClick:(void(^)(NSString *text))clickBlock
{
    QMUITextView *textView = [[QMUITextView alloc] initWithFrame:CGRectMake(RatioWidth(10), RatioWidth(10), RatioWidth(280), RatioWidth(155))];
    textView.textColor = DeepBlackColor;
    textView.font = TGAutoFont(16);
    textView.placeholder = @"请输入终止原因";
    textView.contentInset = UIEdgeInsetsMake(0, 5, 5, 5);
    textView.placeholderColor = LightGrayColor;
    textView.backgroundColor = RGB(246, 246, 246);
    textView.layer.cornerRadius = TableViewCornerRadius;
    
    
    [LEEAlert alert].config
        .LeeStatusBarStyle(UIStatusBarStyleLightContent)
        .LeeMaxWidth(RatioWidth(320)) // 设置最大宽度 (固定数值 横竖屏相同)
        .LeeMaxHeight(RatioWidth(300))
        .LeeAddTitle(^(UILabel * _Nonnull label) {
            label.text = @"拜访终止";
            label.font = TGMediumAFont(18);
            label.textColor = DeepBlackColor;
            label.textAlignment = NSTextAlignmentCenter;
        })
        .LeeAddCustomView(^(LEECustomView *custom) {
            
            custom.view = textView;
            custom.positionType = LEECustomViewPositionTypeCenter;
        })
        .LeeAddAction(^(LEEAction * _Nonnull action) {
            action.borderColor = RGB(231,231,231);
            action.height = RatioWidth(54);
            action.title = @"取消";
            action.titleColor = RGBA(51, 51, 51, 1);
            action.font = TGAutoFont(16);
            action.clickBlock = ^{
            };
        })
        .LeeAddAction(^(LEEAction *action){
            action.borderColor = RGB(231,231,231);
            action.height = RatioWidth(54);
            action.title = @"确定";
            action.titleColor = GlobalBarRedTinColor;
            action.font = TGAutoFont(16);
            action.clickBlock = ^{
                if (EmptyCheck(textView.text)) {
                    [TGProgressHUD showHUDTip:@"请输入终止原因"];
                    return;
                }
                if (clickBlock) {
                    clickBlock(textView.text);
                }
            };
        })
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
        .LeeActionSheetBackgroundColor([UIColor whiteColor])
        .LeeCornerRadii(CornerRadiiMake(10, 10, 10, 10))   // 指定整体圆角半径
        .LeeShow();
    
}


+(void)textViewPatternHeadTitle:(NSString*)headTitle placeholder:(NSString*)placeholder click:(void(^)(NSInteger index,NSString *text))clickBlock
{
    QMUITextView *textView = [[QMUITextView alloc] initWithFrame:CGRectMake(RatioWidth(12), RatioWidth(20), RatioWidth(280), RatioWidth(155))];
    textView.textColor = DeepBlackColor;
    textView.font = TGAutoFont(16);
    textView.placeholder = placeholder;
    textView.contentInset = UIEdgeInsetsMake(0, 5, 5, 5);
    textView.placeholderColor = LightGrayColor;
    textView.backgroundColor = RGB(246, 246, 246);
    textView.layer.cornerRadius = TableViewCornerRadius;
    
    
    [LEEAlert alert].config
        .LeeStatusBarStyle(UIStatusBarStyleLightContent)
        .LeeMaxWidth(RatioWidth(320)) // 设置最大宽度 (固定数值 横竖屏相同)
        .LeeMaxHeight(RatioWidth(300))
        .LeeAddTitle(^(UILabel * _Nonnull label) {
            label.text = headTitle;
            label.font = TGMediumAFont(18);
            label.textColor = DeepBlackColor;
            label.textAlignment = NSTextAlignmentCenter;
        })
        .LeeAddCustomView(^(LEECustomView *custom) {
            
            custom.view = textView;
            custom.positionType = LEECustomViewPositionTypeCenter;
        })
        .LeeAddAction(^(LEEAction * _Nonnull action) {
            action.borderColor = RGB(231,231,231);
            action.height = RatioWidth(54);
            action.title = @"取消";
            action.titleColor = RGBA(51, 51, 51, 1);
            action.font = TGAutoFont(16);
            action.clickBlock = ^{
                
                if (clickBlock)
                {
                    clickBlock(0,textView.text);
                }
            };
        })
        .LeeAddAction(^(LEEAction *action){
            action.borderColor = RGB(231,231,231);
            action.height = RatioWidth(54);
            action.title = @"确定";
            action.titleColor = GlobalBarRedTinColor;
            action.font = TGAutoFont(16);
            action.isClickNotClose=YES;
            action.clickBlock = ^{
        
                if (clickBlock)
                {
                    clickBlock(1,textView.text);
                }
            };
        })
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
        .LeeActionSheetBackgroundColor([UIColor whiteColor])
        .LeeCornerRadii(CornerRadiiMake(10, 10, 10, 10))   // 指定整体圆角半径
        .LeeShow();
    
}

/**
 1.输入框格式textView
 headTitle:标题
 placeholder:textView占位符内容
 第一个按钮:灰色按钮
 第二个按钮:红色按钮
 */

+(void)textViewPatternHeadTitle:(NSString*)headTitle placeholder:(NSString*)placeholder cancelBtnStr:(NSString*)cancelBtnStr sureBtnStr:(NSString*)sureBtnStr click:(void(^)(NSInteger index,NSString *text))clickBlock
{
    QMUITextView *textView = [[QMUITextView alloc] initWithFrame:CGRectMake(RatioWidth(12), RatioWidth(20), RatioWidth(280), RatioWidth(155))];
    textView.textColor = DeepBlackColor;
    textView.font = TGAutoFont(16);
    textView.placeholder = placeholder;
    textView.contentInset = UIEdgeInsetsMake(0, 5, 5, 5);
    textView.placeholderColor = LightGrayColor;
    textView.backgroundColor = RGB(246, 246, 246);
    textView.layer.cornerRadius = TableViewCornerRadius;
    
    
    [LEEAlert alert].config
        .LeeStatusBarStyle(UIStatusBarStyleLightContent)
        .LeeMaxWidth(RatioWidth(320)) // 设置最大宽度 (固定数值 横竖屏相同)
        .LeeMaxHeight(RatioWidth(300))
        .LeeClickBackgroundClose(YES)
        .LeeAddTitle(^(UILabel * _Nonnull label) {
            label.text = headTitle;
            label.font = TGMediumAFont(18);
            label.textColor = DeepBlackColor;
            label.textAlignment = NSTextAlignmentCenter;
        })
        .LeeAddCustomView(^(LEECustomView *custom) {
            
            custom.view = textView;
            custom.positionType = LEECustomViewPositionTypeCenter;
        })
        .LeeAddAction(^(LEEAction * _Nonnull action) {
            action.borderColor = RGB(231,231,231);
            action.height = RatioWidth(54);
            action.title = cancelBtnStr;
            action.titleColor = RGBA(51, 51, 51, 1);
            action.font = TGAutoFont(16);
            action.isClickNotClose=YES;
            action.clickBlock = ^{
                
                if (clickBlock)
                {
                    clickBlock(0,textView.text);
                }
            };
        })
        .LeeAddAction(^(LEEAction *action){
            action.borderColor = RGB(231,231,231);
            action.height = RatioWidth(54);
            action.title = sureBtnStr;
            action.titleColor = GlobalBarRedTinColor;
            action.font = TGAutoFont(16);
            action.isClickNotClose=YES;
            action.clickBlock = ^{
        
                if (clickBlock)
                {
                    clickBlock(1,textView.text);
                }
            };
        })
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
        .LeeActionSheetBackgroundColor([UIColor whiteColor])
        .LeeCornerRadii(CornerRadiiMake(10, 10, 10, 10))   // 指定整体圆角半径
        .LeeShow();
    
}


+(void)textFieldNumPatternHeadTitle:(NSString*)headTitle placeholder:(NSString*)placeholder click:(void(^)(NSString *text))clickBlock
{
    QMUITextField *textField = [[QMUITextField alloc] initWithFrame:CGRectMake(RatioWidth(12), RatioWidth(24), RatioWidth(280), RatioWidth(44))];
    textField.textColor = DeepBlackColor;
    textField.font = TGAutoFont(16);
    textField.placeholder = placeholder;
    textField.textInsets = UIEdgeInsetsMake(0, 5, 5, 5);
    textField.placeholderColor = LightGrayColor;
    textField.keyboardType=UIKeyboardTypeDecimalPad;
    textField.backgroundColor = RGB(246, 246, 246);
    textField.layer.cornerRadius = TableViewCornerRadius;
    
    
    [LEEAlert alert].config
        .LeeStatusBarStyle(UIStatusBarStyleLightContent)
        .LeeMaxWidth(RatioWidth(320)) // 设置最大宽度 (固定数值 横竖屏相同)
        .LeeMaxHeight(RatioWidth(300))
        .LeeAddTitle(^(UILabel * _Nonnull label) {
            label.text = headTitle;
            label.font = TGMediumAFont(18);
            label.textColor = DeepBlackColor;
            label.textAlignment = NSTextAlignmentCenter;
        })
        .LeeAddCustomView(^(LEECustomView *custom) {
            
            custom.view = textField;
            custom.positionType = LEECustomViewPositionTypeCenter;
        })
        .LeeAddAction(^(LEEAction * _Nonnull action) {
            action.borderColor = RGB(231,231,231);
            action.height = RatioWidth(54);
            action.title = @"取消";
            action.titleColor = RGBA(51, 51, 51, 1);
            action.font = TGAutoFont(16);
            action.clickBlock = ^{
            };
        })
        .LeeAddAction(^(LEEAction *action){
            action.borderColor = RGB(231,231,231);
            action.height = RatioWidth(54);
            action.title = @"确定";
            action.isClickNotClose=YES;
            action.titleColor = GlobalBarRedTinColor;
            action.font = TGAutoFont(16);
            action.clickBlock = ^{
                if (EmptyCheck(textField.text)) {
                    [TGProgressHUD showHUDTip:placeholder];
                    return;
                }
                if (clickBlock) {
                    clickBlock(textField.text);
                }
            };
        })
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
        .LeeActionSheetBackgroundColor([UIColor whiteColor])
        .LeeCornerRadii(CornerRadiiMake(10, 10, 10, 10))   // 指定整体圆角半径
        .LeeShow();
    
}


+(void)textFieldTwoContentNumPatternHeadTitle:(NSString*)headTitle oneContent:(NSString*)oneContent twoContent:(NSString*)twoContent placeholder:(NSString*)placeholder delegate:(id<UITextFieldDelegate>)delegate click:(void(^)(NSInteger index,NSString *text,LEEAction*btn))clickBlock
{
    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(RatioWidth(12), RatioWidth(24), RatioWidth(280), RatioWidth(44))];
    textField.textColor = DeepBlackColor;
    textField.font = TGAutoFont(16);
    textField.placeholder = placeholder;
    [textField df_contentMargin:5];
//    textField.placeholderColor = LightGrayColor;
    textField.keyboardType=UIKeyboardTypeDecimalPad;
    textField.backgroundColor = RGB(246, 246, 246);
    textField.layer.cornerRadius = TableViewCornerRadius;
    textField.tag=100;
    textField.delegate= delegate;
    
    [LEEAlert alert].config
        .LeeStatusBarStyle(UIStatusBarStyleLightContent)
        .LeeMaxWidth(RatioWidth(320)) // 设置最大宽度 (固定数值 横竖屏相同)
        .LeeMaxHeight(RatioWidth(300))
        .LeeAddTitle(^(UILabel * _Nonnull label) {
            label.text = headTitle;
            label.font = TGMediumAFont(18);
            label.textColor = DeepBlackColor;
            label.textAlignment = NSTextAlignmentCenter;
        })
        .LeeAddContent(^(UILabel * _Nonnull label) {
            label.text = oneContent;
            label.font = TGMediumAFont(16);
            label.textColor = [UIColor colorWithHexString:@"#666666"];
            label.textAlignment = NSTextAlignmentLeft;
        })
        .LeeAddContent(^(UILabel * _Nonnull label) {
            label.text = twoContent;
            label.font = TGMediumAFont(16);
            label.textColor = [UIColor colorWithHexString:@"#666666"];
            label.textAlignment = NSTextAlignmentLeft;
        })
        .LeeAddCustomView(^(LEECustomView *custom) {
            
            custom.view = textField;
            custom.positionType = LEECustomViewPositionTypeCenter;

            
        })
        .LeeAddAction(^(LEEAction * _Nonnull action) {
            action.borderColor = RGB(231,231,231);
            action.height = RatioWidth(54);
            action.title = @"取消";
            action.titleColor = RGBA(51, 51, 51, 1);
            action.font = TGAutoFont(16);
            __weak LEEAction * weakSelf = action;
            action.clickBlock = ^{
                
                if (clickBlock)
                {
                    clickBlock(0,textField.text,weakSelf);
                }
            };
        })
    
        
        .LeeAddAction(^(LEEAction *action){
            action.borderColor = RGB(231,231,231);
            action.height = RatioWidth(54);
            action.title = @"确定";
            action.titleColor = GlobalBarRedTinColor;
            action.font = TGAutoFont(16);
            action.isClickNotClose=YES;
            __weak LEEAction * weakSelf = action;
            action.clickBlock = ^{
                if (EmptyCheck(textField.text)) {
                    [TGProgressHUD showHUDTip:placeholder];
                    return;
                }
                if (clickBlock) {
                    clickBlock(1,textField.text,weakSelf);
                }
            };
        })
    
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
        .LeeActionSheetBackgroundColor([UIColor whiteColor])
        .LeeCornerRadii(CornerRadiiMake(10, 10, 10, 10))   // 指定整体圆角半径
        .LeeShow();
    
}

//创建清洗弹窗
+(void)workCleanKindAddActionTitle:(NSString *)title click:(void(^)(NSInteger index))clickBlock
{
        [LEEAlert actionsheet].config
        .LeeStatusBarStyle(UIStatusBarStyleLightContent)
        .LeeAddTitle(^(UILabel * _Nonnull label) {
        label.text = title;
        label.font = TGAutoFont(14);
        label.textColor = LightGrayColor;
        label.textAlignment = NSTextAlignmentCenter;
        })
        .LeeAddAction(^(LEEAction * _Nonnull action) {
        action.title = @"外协清洗";
        action.titleColor = RGBA(51, 51, 51, 1);
        action.font = TGAutoFont(16);
        action.clickBlock = ^{
        if (clickBlock) {
        clickBlock(0);
        }
        };
        })
        .LeeAddAction(^(LEEAction * _Nonnull action) {
        action.title = @"内部清洗";
        action.titleColor = RGBA(51, 51, 51, 1);
        action.font = TGAutoFont(16);
        action.clickBlock = ^{
        if (clickBlock) {
        clickBlock(1);
        }
        };
        })
   
        .LeeAddAction(^(LEEAction * _Nonnull action) {
        action.title = @"取消";
        action.titleColor = RGBA(51, 51, 51, 1);
        action.font = TGAutoFont(16);
        action.clickBlock = ^{
        };
        })
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
        .LeeActionSheetBackgroundColor([UIColor whiteColor])
        .LeeCornerRadii(CornerRadiiMake(10, 10, 0, 0))   // 指定整体圆角半径
        .LeeConfigMaxWidth(^CGFloat(LEEScreenOrientationType type, CGSize size)  {
        return CGRectGetWidth([[UIScreen mainScreen] bounds]);
        }).LeeShow();

}

//带有TextView的弹窗 创建拜访详情中拜访终止、商机失败
+(void)alertTextViewWithTitle:(NSString *)title placeHoder:(NSString *)placeHoder actionClick:(void(^)(NSString *text))clickBlock {
    QMUITextView *textView = [[QMUITextView alloc] initWithFrame:CGRectMake(RatioWidth(10), RatioWidth(10), RatioWidth(280), RatioWidth(155))];
    textView.textColor = DeepBlackColor;
    textView.font = TGAutoFont(16);
    textView.placeholder = placeHoder?:@"请输入";
    textView.contentInset = UIEdgeInsetsMake(0, 5, 5, 5);
    textView.placeholderColor = LightGrayColor;
    textView.backgroundColor = RGB(246, 246, 246);
    textView.layer.cornerRadius = TableViewCornerRadius;
    
    [LEEAlert alert].config
        .LeeStatusBarStyle(UIStatusBarStyleLightContent)
        .LeeMaxWidth(RatioWidth(320)) // 设置最大宽度 (固定数值 横竖屏相同)
        .LeeMaxHeight(RatioWidth(300))
        .LeeAddTitle(^(UILabel * _Nonnull label) {
            label.text = title?:@"标题";
            label.font = TGMediumAFont(18);
            label.textColor = DeepBlackColor;
            label.textAlignment = NSTextAlignmentCenter;
        })
        .LeeAddCustomView(^(LEECustomView *custom) {
            
            custom.view = textView;
            custom.positionType = LEECustomViewPositionTypeCenter;
        })
        .LeeAddAction(^(LEEAction * _Nonnull action) {
            action.borderColor = RGB(231,231,231);
            action.height = RatioWidth(54);
            action.title = @"取消";
            action.titleColor = RGBA(51, 51, 51, 1);
            action.font = TGAutoFont(16);
            action.clickBlock = ^{
            };
        })
        .LeeAddAction(^(LEEAction *action){
            action.borderColor = RGB(231,231,231);
            action.height = RatioWidth(54);
            action.title = @"确定";
            action.titleColor = GlobalBarRedTinColor;
            action.font = TGAutoFont(16);
            action.clickBlock = ^{
                if (EmptyCheck(textView.text)) {
                    [TGProgressHUD showHUDTip:placeHoder];
                    return;
                }
                if (clickBlock) {
                    clickBlock(textView.text);
                }
            };
        })
        .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
        .LeeActionSheetBackgroundColor([UIColor whiteColor])
        .LeeCornerRadii(CornerRadiiMake(10, 10, 10, 10))   // 指定整体圆角半径
        .LeeShow();
    
}

+(void)actionSheetTitle:(NSString *)title
                buttons:(NSArray *)buttons
     isHaveCancleAction:(BOOL)isHaveCancleAction
                  click:(void(^)(NSInteger index))clickBlock {
    
    [self actionSheetTitle:title buttons:buttons isHaveCancleAction:isHaveCancleAction canClickBackgroundClose:NO click:clickBlock];
}

+(void)actionSheetTitle:(NSString *)title
                buttons:(NSArray *)buttons
     isHaveCancleAction:(BOOL)isHaveCancleAction
canClickBackgroundClose:(BOOL)canClickBackgroundClose
                  click:(void(^)(NSInteger index))clickBlock {
    
    LEEActionSheetConfig *config = (LEEActionSheetConfig *)[LEEAlert actionsheet];
    
    config.config
    .LeeActionSheetBottomMargin(0)
    .LeeStatusBarStyle(UIStatusBarStyleLightContent)
    .LeeActionSheetBackgroundColor([UIColor whiteColor])
    .LeeClickBackgroundClose(canClickBackgroundClose)
    .LeeConfigMaxWidth(^CGFloat(LEEScreenOrientationType type, CGSize size)  {
    return CGRectGetWidth([[UIScreen mainScreen] bounds]);
   });
    if (!EmptyCheck(title)) {
        config.config
        .LeeAddTitle(^(UILabel * _Nonnull label) {
            label.text = title;
            label.font = TGAutoFont(14);
            label.textColor = LightGrayColor;
            label.textAlignment = NSTextAlignmentCenter;
        });
    }
    for (int i=0; i<buttons.count; i++) {
        NSString *str = buttons[i];
        config.config.LeeAddAction(^(LEEAction * _Nonnull action) {
            action.title = str;
            action.titleColor = RGBA(51, 51, 51, 1);
            action.font = TGAutoFont(16);
            action.clickBlock = ^{
                if (clickBlock) {
                    clickBlock(i);
                }
            };
        });
    }
    
    if (isHaveCancleAction) {
        config.config.LeeAddAction(^(LEEAction * _Nonnull action) {
           action.title = @"取消";
   //        action.type = LEEActionTypeCancel;
           action.titleColor = LightGrayColor;
           action.font = TGAutoFont(16);

        });
    }
    config.config.LeeShow();
}

+(void)actionSheetButtons:(NSArray *)buttons click:(void(^)(NSInteger index))clickBlock{
    
    LEEActionSheetConfig *config = (LEEActionSheetConfig *)[LEEAlert actionsheet];
    
    config.config
    .LeeActionSheetBottomMargin(0)
    .LeeStatusBarStyle(UIStatusBarStyleLightContent)
    .LeeActionSheetBackgroundColor([UIColor whiteColor])
    .LeeConfigMaxWidth(^CGFloat(LEEScreenOrientationType type, CGSize size)  {
    return CGRectGetWidth([[UIScreen mainScreen] bounds]);
    }).LeeMaxHeight(RatioWidth(500));
    for (int i=0; i<buttons.count; i++) {
        NSString *str = buttons[i];
        config.config.LeeAddAction(^(LEEAction * _Nonnull action) {
            action.title = str;
            action.titleColor = RGBA(51, 51, 51, 1);
            action.font = TGAutoFont(16);
            action.textAlignment = NSTextAlignmentCenter;
            if ([str containsString:@"\n"]) {
                action.numberOfLines = 2;
                action.height = RatioWidth(50);
                action.font = TGAutoFont(14);
                
                NSMutableAttributedString *att = [[NSMutableAttributedString alloc] initWithString:str];
                NSString *str1 = [[str componentsSeparatedByString:@"\n"] firstObject];
                NSString *str2 = [[str componentsSeparatedByString:@"\n"] lastObject];
                [att addAttributes:@{NSForegroundColorAttributeName:DeepBlackColor} range:[str rangeOfString:str1]];
                [att addAttributes:@{NSForegroundColorAttributeName:LightGrayColor} range:[str rangeOfString:str2]];
                action.attributedTitle = att;
                
            }
            
            action.clickBlock = ^{
                if (clickBlock) {
                    clickBlock(i);
                }
            };
        });
    }
    
     config.config.LeeAddAction(^(LEEAction * _Nonnull action) {
        action.title = @"取消";
//        action.type = LEEActionTypeCancel;
        action.titleColor = LightGrayColor;
        action.font = TGAutoFont(16);

    })
     .LeeShow();

}

+ (void)alertTitle:(NSString *)title after:(NSInteger)after {
        
        LEEAlertConfig *config =  [LEEAlert alert];
    //    config.config.LeeClickBackgroundClose(flag);
        config.config.LeeMaxWidth(RatioWidth(270));
        config.config.LeeStatusBarStyle(UIStatusBarStyleLightContent);
        config.config.LeeBackgroundStyleTranslucent(.4);
        config.config.LeeCornerRadius(TableViewCornerRadius);
        config.config.LeeShadowOpacity(0.2);
    config.config.LeeIdentifier(@"1");

        if (title) {
            config.config.LeeAddTitle(^(UILabel * _Nonnull label) {
                label.textColor = RGBA(60, 60, 60, 1);
                label.font = TGBlodAFont(16);
                label.text = title;
            });
        }
     
        config.config.LeeShow();
    // 模拟5秒后关闭指定标识的alert
      dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(after * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
          [LEEAlert closeWithIdentifier:@"1" completionBlock:^{
              // 关闭完成
          }];
      });
    
}


+ (void)eventAlertTitle:(NSString*)title message:(NSString *)message cancelTitle:(NSString*)cancelTitle sureTitle:(NSString*)sureTitle  clickBackgroundClose:(BOOL)flag click:(void(^)(NSInteger index))clickBlock  {
    
    
    LEEAlertConfig *config =  [LEEAlert alert];
    config.config.LeeClickBackgroundClose(flag);
    config.config.LeeMaxWidth(SCREEN_WIDTH-RatioWidth(68));
    config.config.LeeStatusBarStyle(UIStatusBarStyleLightContent);
    config.config.LeeBackgroundStyleTranslucent(.4);
    config.config.LeeCornerRadius(TableViewCornerRadius);
    config.config.LeeShadowOpacity(0.2);
    config.config.LeeCornerRadius(10);
    if (title) {
        config.config.LeeAddTitle(^(UILabel *label) {
            label.text = title;
            label.textColor = RGB(29,33, 41);
            label.font = [TG_UIHelper TGAutoFount:18 name:Ping_Medium];
        });
    }
    config.config.LeeAddContent(^(UILabel *label) {
        label.textColor = RGB(78,89, 105);
        NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
        paraStyle.lineSpacing = 8.0;
        paraStyle.alignment = NSTextAlignmentCenter;
        label.attributedText = [[NSMutableAttributedString alloc] initWithString:message attributes: @{NSFontAttributeName:  TGAutoFont(15), NSParagraphStyleAttributeName: paraStyle}];
    });
    if (cancelTitle) {
        config.config.LeeAddAction(^(LEEAction *action){
            action.borderColor = RGB(231,231,231);
            action.title = cancelTitle;
            action.titleColor = DeepGrayColor;
            action.font = TGMediumAFont(16);
            action.height = RatioWidth(50);
            action.clickBlock = ^{
                if (clickBlock) {
                    clickBlock(0);
                }
            };
        });
    }
    if (sureTitle) {
        config.config.LeeAddAction(^(LEEAction *action){
            action.borderColor = RGB(231,231,231);
            action.title = sureTitle;
            action.titleColor = RGBA(22, 93, 255, 1);
            action.font = TGMediumAFont(16);
            action.height = RatioWidth(50);
            action.clickBlock = ^{
                if (clickBlock) {
                    clickBlock(1);
                }
            };
        });
    }
    
    config.config.LeeShow();
    
//    return config;
    
}

+ (void)eventAlertTipImage:(NSString *)imgName andMessage:(NSString *)message cancel:(NSString*)cancel  click:(void(^)(NSInteger index))clickBlock{
   

    [LEEAlert alert].config
    .LeeStatusBarStyle(UIStatusBarStyleLightContent)
    .LeeMaxWidth(SCREEN_WIDTH-RatioWidth(68)) // 设置最大宽度 (固定数值 横竖屏相同)
    .LeeAddCustomView(^(LEECustomView *custom) {
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
        imageView.image = kImage(imgName);
        custom.view = imageView;
        custom.positionType = LEECustomViewPositionTypeCenter;
    }).LeeAddContent(^(UILabel *label) {
        label.text = message;
        label.font = [TG_UIHelper TGAutoFount:18 name:Ping_Medium];
        label.textColor = RGBA(29, 33, 41, 1);
        
    }).LeeAddAction(^(LEEAction *action){
        action.title = cancel;
        action.titleColor = RGBA(22, 93, 255, 1);
        action.font = TGAutoFont(16);
        action.clickBlock = ^{
            if (clickBlock) {
                clickBlock(0);
            }
        };
    })
    .LeeShow();
}

+ (void)alertRejectWithBlock:(void(^)(NSString *reason))block{
    LEEActionSheetConfig *alert = [LEEAlert actionsheet];
    QMUITextView *textView = [[QMUITextView alloc] initWithFrame:CGRectMake(RatioWidth(10), 48, SCREEN_WIDTH - RatioWidth(20), RatioWidth(180))];
    textView.textColor = DeepBlackColor;
    textView.font = TGAutoFont(16);
    textView.placeholder = @"请输入";
    textView.contentInset = UIEdgeInsetsMake(0, 5, 5, 5);
    textView.placeholderColor = LightGrayColor;
    textView.backgroundColor = [UIColor whiteColor];
    textView.layer.cornerRadius = TableViewCornerRadius;
    
    UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, RatioWidth(266))];
    UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 28)];
    [contentView addSubview:topView];
    [contentView addSubview:textView];
    
    QMUIButton *cancelBtn = [[QMUIButton alloc] init];
    [cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
    [cancelBtn setTitleColor:RGBA(134, 144, 156, 1) forState:UIControlStateNormal];
    cancelBtn.titleLabel.font = TGAutoFont(16);
    [topView addSubview:cancelBtn];
    [cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.bottom.mas_equalTo(0);
    }];
    [cancelBtn addBlockForControlEvents:UIControlEventTouchUpInside block:^(id  _Nonnull sender) {
        [LEEAlert closeWithIdentifier:@"close_reject" completionBlock:^{
            
        }];
    }];
    
    QMUIButton *sureBtn = [[QMUIButton alloc] init];
    [sureBtn setTitle:@"确定" forState:UIControlStateNormal];
    [sureBtn setTitleColor:RGBA(134, 144, 156, 1) forState:UIControlStateNormal];
    sureBtn.titleLabel.font = TGAutoFont(16);
    [topView addSubview:sureBtn];
    [sureBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-16);
        make.top.bottom.mas_equalTo(0);
    }];
    [sureBtn addBlockForControlEvents:UIControlEventTouchUpInside block:^(id  _Nonnull sender) {
        if (textView.text.length == 0) {
            [TGProgressHUD showHUDTip:@"请输入驳回原因"];
            return;
        }
        if (block){
            block(textView.text);
        }
        [LEEAlert closeWithIdentifier:@"close_reject" completionBlock:^{
            
        }];
    }];
    
    QMUILabel *titleLabel = [[QMUILabel alloc] init];
    titleLabel.text = @"驳回原因";
    titleLabel.textColor = RGBA(29, 33, 41, 1);
    titleLabel.font = [TG_UIHelper TGAutoFount:18 name:Ping_Medium];
    [topView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(topView.mas_centerX);
        make.centerY.mas_equalTo(topView.mas_centerY);
    }];
    
    alert.config
    .LeeMaxWidth(SCREEN_WIDTH)
    .LeeMaxHeight(RatioWidth(300))
    .LeeStatusBarStyle(UIStatusBarStyleLightContent)
    .LeeIdentifier(@"close_reject")
    .LeeAddCustomView(^(LEECustomView *custom) {
        custom.view = contentView;
        custom.positionType = LEECustomViewPositionTypeCenter;
    })
    .LeeActionSheetBottomMargin(0.0) // 设置底部距离屏幕的边距
    .LeeActionSheetBackgroundColor([UIColor whiteColor])
    .LeeCornerRadii(CornerRadiiMake(10, 10, 0, 0))   // 指定整体圆角半径
    .LeeAvoidKeyboard(YES)
    .LeeShow();
}

@end
